package com.sskj.finance.http;

import com.lzy.okgo.request.GetRequest;
import com.sskj.finance.bean.BalanceCqtfBean;
import com.sskj.finance.bean.FinanBannerBean;
import com.sskj.finance.bean.FinanRecordInfoBean;
import com.sskj.finance.bean.FinanInfoBean;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.PostRequest;
import com.sskj.common.base.HttpData;
import com.sskj.finance.bean.FinanBean;
import com.sskj.lib.bean.PageBean;

import java.util.List;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {


    /**
     * 发短信
     *
     * @return
     */
    public GetRequest<HttpData> sendSms(String mobile) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.SEND_SMS)
                .params("mobile", mobile)
                .params("type", 5)
                ;
    }


    /**
     * 理财产品列表
     *
     * @return
     */
    public PostRequest<HttpData<PageBean<FinanBean>>> finanList(String p, String size) {
        return OkGo.<HttpData<PageBean<FinanBean>>>post(HttpConfig.BASE_URL + HttpConfig.FINAN_LIST)
                .params("p", p)
                .params("size", size)
                ;
    }

    /**
     * 认购理财产品
     *
     * @param id   红利记录id
     * @param num  认购数量
     * @param code 短信验证码，type=5
     * @return
     */
    public PostRequest<HttpData> createOrder(String id, String num, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CREATE_ORDER)
                .params("id", id)
                .params("num", num)
                .params("code", code);
    }

    /**
     * 理财产品详情
     *
     * @param id 理财产品id
     * @return
     */
    public PostRequest<HttpData<FinanInfoBean>> finanInfo(String id) {
        return OkGo.<HttpData<FinanInfoBean>>post(HttpConfig.BASE_URL + HttpConfig.FINAN_INFO)
                .params("id", id);
    }

    /**
     * 我的订单
     *
     * @param p    页码，默认1
     * @param size 每页多少条，默认15
     * @return
     */
    public PostRequest<HttpData<PageBean<FinanRecordInfoBean>>> finanRecordInfo(String p, String size) {
        return OkGo.<HttpData<PageBean<FinanRecordInfoBean>>>post(HttpConfig.BASE_URL + HttpConfig.FINAN_RECORD_INFO)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 轮播通知
     *
     * @return
     */
    public GetRequest<HttpData<List<String>>> finanBanner(){
        return OkGo.<HttpData<List<String>>>get(HttpConfig.BASE_URL + HttpConfig.FINAN_BANNER);
    }


    public PostRequest<HttpData<BalanceCqtfBean>> getBalance() {
        return OkGo.<HttpData<BalanceCqtfBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_BALANCE);

    }
}